
package com.feib.soeasy.job.dao.hibernate;

import java.util.Date;

import javax.annotation.Resource;

import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;

import com.feib.soeasy.job.dao.ForceLogoutDao;


/**
 * @title (#)ForceLogoutHibernateDao.java<br>
 * @description <br>
 * @author Jimmy Liu<br>
 * @version 1.0.0 2010/11/25
 * @copyright Far Eastern International Bank Copyright (c) 2010<br>
 * @2010/12/16 create by Jimmy Liu<br>
 */
@Repository("forceLogoutDao")
public class ForceLogoutHibernateDao extends HibernateDaoSupport implements ForceLogoutDao {

    @Resource(name = "sessionFactory")
    public void setMySessionFactory(SessionFactory sessionFactory) {
        super.setSessionFactory(sessionFactory);
    }
    
    /* (non-Javadoc)
     * @see com.feib.soeasy.job.dao.ForceLogoutDao#logout(java.util.Date)
     */
    @Override
    public void logout(Date before) {
        StringBuffer hql = new StringBuffer();
        hql.append("update UserLoginControl set actived = false  ");
        hql.append("where activityTime <= ? ");
        hql.append("and actived = true ");
        
        this.getHibernateTemplate().bulkUpdate(hql.toString(), before);

    }

}
